package com.rzhd.coursepatriarch.common.utils.base;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author yql
 * @date: 2018/7/2.
 */
public class BaseSharedPreferenceUtils {

    private Context mContext;
    private final String TAG = getClass().getSimpleName();

    private static BaseSharedPreferenceUtils sharedPreferenceUtils;
    /**
     * 创建一个写入器
     */
    private SharedPreferences preferences;
    private SharedPreferences.Editor editor;

    public BaseSharedPreferenceUtils(Context context) {
        this.mContext = context;
        preferences = context.getSharedPreferences(TAG, Context.MODE_PRIVATE);
        editor = preferences.edit();
    }

    public static BaseSharedPreferenceUtils getInstance(Context context) {
        if (sharedPreferenceUtils == null) {
            synchronized (BaseSharedPreferenceUtils.class) {
                if (sharedPreferenceUtils == null) {
                    sharedPreferenceUtils = new BaseSharedPreferenceUtils(context);
                }
            }
        }
        return sharedPreferenceUtils;
    }

}
